<?php
if ($_POST['promoter']) $where = "WHERE (`promoter`='".$_POST['promoter']."' OR `promoter2`='".$_POST['promoter']."' OR `promoter3`='".$_POST['promoter']."') ";
if (!$_POST['status']) {
	if (!$where) $where = " WHERE ";
	else $where .= " AND ";
	$where .= " (`status`<'3') ";
} else {
	if (!$where) $where = " WHERE ";
	else $where .= " AND ";
	$where .= " (`status`='".mysql_real_escape_string($_POST['status'])."') ";
}
if ($_POST['searchFor'] && $_POST['searchFor'] !== 'Search') $where .= " AND ((LOWER(`artist`) LIKE '%".mysql_real_escape_string($_POST['searchFor'])."%') OR (LOWER(`title`) LIKE '%".mysql_real_escape_string($_POST['searchFor'])."%')) ";
$query = "SELECT * FROM `album` ". $where . "ORDER BY TRIM(LEADING 'the ' FROM LOWER(`artist`)) ASC ";
$result = mysql_query($query) or die(mysql_error());
?>
<form action="<?=$_SERVER[PHP_SELF]?>" method="post">
<fieldset>
<legend>Display Options</legend>
<input type="text" name="searchFor" value="Search" onblur="if (value == '') {value = 'Search'}" onfocus="if (value == 'Search') {value =''}" value="Search"  />
<select name="promoter">
<option value="" selected="selected">promoter:</option>
<?php
$promoter_sql = "SELECT `id`,`nickname`,`company` FROM `promoter` ORDER BY `company`";
$promoter_result = mysql_query($promoter_sql);
while ($promoter_row = mysql_fetch_row($promoter_result)) {
?><option value="<?=$promoter_row[0]?>" <?php if ($_POST['promoter'] == $promoter_row[0]) echo('selected="selected"') ?>><?=$promoter_row[1]?>@<?=$promoter_row[2]?></option>
<?php
}
?></select><select name="status"><option value="" selected="selected">Status:</option><option value="0">Not in</option><option value="1">In review</option><option value="2">In Rotation</option><option value="3">Old</option><option value="4">Archived</option><option value="5">Gone.</option></select>
<input type="hidden" name="cat" value="<?=$cat?>" />
<input type="hidden" name="mode" value="cdlistedit" />
<input type="submit" value="Go Go!" />
</fieldset>
</form>